package org.helgoboss.jintellitype_test

import org.osgi.framework.{BundleActivator, BundleContext}
import org.helgoboss.osgi_additions.{OsgiLogging, OsgiConsumer}
import com.melloware.jintellitype.{JIntellitype, HotkeyListener, JIntellitypeConstants}
import java.awt.Event
// import org.helgoboss.user_notification.{NotificationService, Info}

class JIntellitypeTest extends BundleActivator with OsgiLogging with OsgiConsumer {
    
    private var it: JIntellitype = _
    
    // private val notificationService = requiredService[NotificationService]
    
    private val listener = new HotkeyListener {
        def onHotKey(id: Int) {
//            optionalService[NotificationService].foreach {
//                _.notifyUser(Info, "Hallo")
//            }
//            notificationService.notifyUser(Info, "Hallo", None, None, None)
        }
    }
    
    
	override def start(context: BundleContext) {
        super.start(context)
        it = JIntellitype.getInstance
        it addHotKeyListener listener
        it.registerHotKey(1, JIntellitypeConstants.MOD_WIN, 'A'.asInstanceOf[Int])
        // it.registerHotKey(2, Event.META_MASK, 'C'.asInstanceOf[Int])
	}
    
    
	
	override def stop(context: BundleContext) {
        it unregisterHotKey 1
        it removeHotKeyListener listener
        // it.unregisterHotKey(2)
        // it.cleanUp
        it = null
        super.stop(context)
	}
    
}